import QtQuick 2.12
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.3
import QtQuick.Window 2.12
import FluentUI 1.0

Item {
    id: app

    Connections{
        target: FluTheme
        function onDarkModeChanged(){
            SettingsHelper.setBoolData("DarkMode", FluTheme.darkMode);
        }
    }

    Connections{
        target: FluApp
        function onUseSystemAppBarChanged(){
            SettingsHelper.setBoolData("UseSystemAppBar", FluApp.useSystemAppBar);
        }
    }

    Component.onCompleted: {
        FluNetwork.openLog = false;
        FluNetwork.setInterceptor(param => {
            param.addHeader("Token","000000000000000000000");
        })
        FluApp.init(app);
        FluApp.windowIcon = "qrc:/SynoMusicPlayer/Resources/Images/Icons/logo.png";
        FluApp.useSystemAppBar = SettingsHelper.getBoolData("UseSystemAppBar", false);
        FluTheme.darkMode = SettingsHelper.getBoolData("DarkMode", true);
        FluTheme.enableAnimation = true;
        FluApp.routes = {
            "/": "qrc:/SynoMusicPlayer/Views/Windows/MainWindow.qml",
            "/about": "qrc:/SynoMusicPlayer/Views/Windows/AboutWindow.qml"
        };
        var args = Qt.application.arguments;
        if(args.length>=2 && args[1].startsWith("-crashed=")){
            FluApp.navigate("/crash",{crashFilePath:args[1].replace("-crashed=","")});
        }else{
            FluApp.navigate("/");
        }
    }
}
